In [1]:
import os, sys
sys.path.insert(0, '/home/trax/trax/website')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trax.settings")
import django
django.setup()
from tracks.models import Track, Laptime
from players.models import Player

Fetch the users


In [9]:
a, b = Player.objects.filter(username__icontains='killsw')
print(a,b)
a.last_login, b.last_login


thekillswitchh thekillswitchhh
Out[9]:
(datetime.datetime(2017, 3, 14, 14, 28, 17, 617001, tzinfo=<UTC>),
 datetime.datetime(2017, 3, 7, 11, 7, 46, 861288, tzinfo=<UTC>))

In [15]:
print("Tracks:")
for t in Track.objects.filter(creator=b):
    print(t)
print("Laptimes:")
for l in Laptime.objects.filter(player=b):
    print(l.track)


Tracks:
Laptimes:
The Epsilon Racetrack

In [17]:
l.player = a
l.save()

In [21]:
print(b.track_set.all())
print(b.laptime_set.all())
print(b.logentry_set.all())
print(b.pitaparticipation_set.all())
print(b.pitassistant_set.all())
print(b.pitlogentry_set.all())
print(b.playervehicle_set.all())
print(b.ssrparticipation_set.all())
print(b.staggeredstartrace_set.all())


<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>

In [23]:
# b.delete()

In [ ]: